function superEgg(K, N) {
    if (N == 0 || K == 1) return N;
    const dp = Array.from(Array(K + 1), () => Array(N + 1).fill(0));

    let m = 0;
    while (dp[K][m] < N) {
        m++;
        for (let i = 1; i <= K; i++) {
            dp[i][m] = dp[i][m - 1] + dp[i - 1][m - 1] + 1;
        }
    }
    return m;
}
